home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / cmds / cvs / sprite / RCS / collect_sets.c,v < prev    next >
Encoding:
Text File  |  1991-09-10  |  8.5 KB  |  346 lines

  1. head     1.2;
  2. branch   ;
  3. access   ;
  4. symbols  ;
  5. locks    ; strict;
  6. comment  @ * @;
  7.  
  8.  
  9. 1.2
  10. date     91.09.10.16.15.16;  author jhh;  state Exp;
  11. branches ;
  12. next     1.1;
  13.  
  14. 1.1
  15. date     91.09.04.22.34.42;  author jhh;  state Exp;
  16. branches ;
  17. next     ;
  18.  
  19.  
  20. desc
  21. @@
  22.  
  23.  
  24. 1.2
  25. log
  26. @removed a bogus warning
  27. @
  28. text
  29. @#ifndef lint
  30. static char rcsid[] = "$Id: collect_sets.c,v 1.15.1.1 91/01/29 07:16:13 berliner Exp $";
  31. #endif !lint
  32.  
  33. /*
  34.  *    Copyright (c) 1989, Brian Berliner
  35.  *
  36.  *    You may distribute under the terms of the GNU General Public License
  37.  *    as specified in the README file that comes with the CVS 1.0 kit.
  38.  *
  39.  * Collect Sets
  40.  *
  41.  *    Collects the interesting file names from the administration and
  42.  *    the repository in a number of variables:
  43.  *                            solved by:
  44.  *        Clist    conflict-ridden            (user)
  45.  *        Glist    modified, needs merging        (update)
  46.  *        Mlist    modified, needs checking in    (commit)
  47.  *        Olist    needs checking out        (update)
  48.  *        Alist    to be added            (commit)
  49.  *        Rlist    to be removed            (commit)
  50.  *        Wlist    remove entry            (update)
  51.  *        Llist    locked list            (commit)
  52.  *        Blist    branch list            (commit)
  53.  *        Dlist    directory list            (update)
  54.  *
  55.  *    Returns non-zero on error.
  56.  */
  57.  
  58. #include <sys/param.h>
  59. #include "cvs.h"
  60.  
  61. extern char update_dir[];
  62.  
  63. Collect_Sets(argc, argv)
  64.     int argc;
  65.     char *argv[];
  66. {
  67.     register int i;
  68.     char tmp[MAXPATHLEN], update_user[MAXPATHLEN];
  69.     int ret = 0;
  70.  
  71.     /*
  72.      * By default, a call here must wipe the slate clean
  73.      */
  74.     Clist[0] = Glist[0] = Mlist[0] = Olist[0] = Dlist[0] = '\0';
  75.     Alist[0] = Rlist[0] = Wlist[0] = Llist[0] = Blist[0] = '\0';
  76.     for (i = 0; i < argc; i++) {
  77.     (void) strcpy(User, argv[i]);
  78.     if (update_dir[0] != '\0')
  79.         (void) sprintf(update_user, "%s/%s", update_dir, User);
  80.     else
  81.         (void) strcpy(update_user, User);
  82.     if (force_tag_match && (Tag[0] != '\0' || Date[0] != '\0'))
  83.         Locate_RCS();
  84.     else
  85.         (void) sprintf(Rcs, "%s/%s%s", Repository, User, RCSEXT);
  86.     if (isdir(User)) {        /* just a directory -- add to Dlist */
  87.         (void) strcat(Dlist, " ");
  88.         (void) strcat(Dlist, User);
  89.         continue;
  90.     }
  91.     Version_TS(Rcs, Tag, User);
  92.     if (VN_User[0] == '\0') {
  93.         /*
  94.          * No entry available, TS_Rcs is invalid
  95.          */
  96.         if (VN_Rcs[0] == '\0') {
  97.         /*
  98.          * There is no RCS file either
  99.          */
  100.         if (TS_User[0] == '\0')    { /* there is no user file */
  101.             if (!force_tag_match || !isfile(Rcs)) {
  102.             warn(0, "nothing known about %s", update_user);
  103.             ret++;
  104.             }
  105.         } else {        /* there is a user file */
  106.             if (!force_tag_match) {
  107.             warn(0, "use `cvs add' to create entry for %s",
  108.                  update_user);
  109.             ret++;
  110.             }
  111.         }
  112.         } else {
  113.         /*
  114.          * There is an RCS file
  115.          */
  116.         if (TS_User[0] == '\0') {
  117.             /*
  118.              * There is no user file; ad it to the Olist
  119.              */
  120.             (void) strcat(Olist, " ");
  121.             (void) strcat(Olist, User);
  122.         } else {
  123.             /*
  124.              * There is a user file; print a warning and add it
  125.              * to the conflict list, Clist, only if it is indeed
  126.              * different from what we plan to extract
  127.              */
  128.             No_Difference(0);
  129.             if (strcmp(TS_Rcs, TS_User) == 0) {
  130.             (void) strcat(Olist, " ");
  131.             (void) strcat(Olist, User);
  132.             } else {
  133.             warn(0, "move away %s; it is in the way",
  134.                  update_user);
  135.             (void) strcat(Clist, " ");
  136.             (void) strcat(Clist, User);
  137.             ret++;
  138.             }
  139.         }
  140.         }
  141.     } else if (VN_User[0] == '0' && VN_User[1] == '\0') {
  142.         /*
  143.          * An entry for a new-born file; TS_Rcs is dummy
  144.          */
  145.         if (TS_User[0] == '\0') {
  146.         /*
  147.          * There is no user file, but there should be one;
  148.          * add it to the remove entry list.
  149.          */
  150.         warn(0, "warning: new-born %s has disappeared", update_user);
  151.         (void) strcat(Wlist, " ");
  152.         (void) strcat(Wlist, User);
  153.         } else {
  154.         /*
  155.          * There is a user file
  156.          */
  157.         if (VN_Rcs[0] == '\0') {
  158.             /*
  159.              * There is no RCS file, so add it to the add entry list
  160.              */
  161.             (void) strcat(Alist, " ");
  162.             (void) strcat(Alist, User);
  163.         } else {
  164.             /*
  165.              * There is an RCS file, so someone else must have
  166.              * checked one in behind our back; added to the conflict
  167.              * list
  168.              */
  169.             warn(0, "conflict: %s created independently by second party",
  170.              update_user);
  171.             (void) strcat(Clist, " ");
  172.             (void) strcat(Clist, User);
  173.             ret++;
  174.         }
  175.         }
  176.     } else if (VN_User[0] == '-') {
  177.         /*
  178.          * An entry for a removed file, TS_Rcs is invalid
  179.          */
  180.         if (TS_User[0] == '\0') {
  181.         /*
  182.          * There is no user file (as it should be)
  183.          */
  184.         (void) sprintf(tmp, "-%s", VN_Rcs);
  185.         if (strcmp(tmp, "-") == 0) {
  186.             /*
  187.              * There is no RCS file; this is all-right, but it
  188.              * has been removed independently by a second party;
  189.              * added to the remove entry list.
  190.              */
  191.             (void) strcat(Wlist, " ");
  192.             (void) strcat(Wlist, User);
  193.         } else if (strcmp(tmp, VN_User) == 0) {
  194.             /*
  195.              * The RCS file is the same version as the user file,
  196.              * and that's OK; added to the to be removed list
  197.              */
  198.             (void) strcat(Rlist, " ");
  199.             (void) strcat(Rlist, User);
  200.         } else {
  201.             /*
  202.              * The RCS file is a newer version than the user file;
  203.              * and this is defintely not OK; make it a conflict.
  204.              */
  205.             warn(0, "conflict: removed %s was modified by second party",
  206.              update_user);
  207.             (void) strcat(Clist, " ");
  208.             (void) strcat(Clist, User);
  209.             ret++;
  210.         }
  211.         } else {
  212.         /*
  213.          * The user file shouldn't be there
  214.          */
  215.         warn(0, "%s should be removed and is still there", update_user);
  216.         ret++;
  217.         }
  218.     } else {
  219.         /*
  220.          * A normal entry, TS_Rcs is valid
  221.          */
  222.         if (VN_Rcs[0] == '\0') {
  223.         /*
  224.          * There is no RCS file
  225.          */
  226.         if (TS_User[0] == '\0') {
  227.             /*
  228.              * There is no user file, so just remove the entry
  229.              */
  230.             warn(0, "warning: %s is not (any longer) pertinent",
  231.              update_user);
  232.             (void) strcat(Wlist, " ");
  233.             (void) strcat(Wlist, User);
  234.         } else if (strcmp(TS_User, TS_Rcs) == 0) {
  235.             /*
  236.              * The user file is still unmodified, so just remove it
  237.              * from the entry list
  238.              */
  239.             if (!force_tag_match || !isfile(Rcs)) {
  240. #if 0
  241.             warn(0, "%s is no longer in the repository",
  242.                  update_user);
  243. #endif
  244.             (void) strcat(Wlist, " ");
  245.             (void) strcat(Wlist, User);
  246.             }
  247.         } else {
  248.             /*
  249.              * The user file has been modified and since it is no
  250.              * longer in the repository, a conflict is raised
  251.              */
  252.             if (!force_tag_match) {
  253.             Locate_RCS();
  254.             (void) No_Difference(0);
  255.             if (strcmp(TS_User, TS_Rcs) == 0) {
  256.                 warn(0,
  257.         "warning: %s is not (any longer) pertinent",
  258.                  update_user);
  259.                 (void) strcat(Wlist, " ");
  260.                 (void) strcat(Wlist, User);
  261.             } else {
  262.                 warn(0,
  263.         "conflict: %s is modified but no longer in the repository",
  264.                  update_user);
  265.                 (void) strcat(Clist, " ");
  266.                 (void) strcat(Clist, User);
  267.                 ret++;
  268.             }
  269.             }
  270.         }
  271.         } else if (strcmp(VN_Rcs, VN_User) == 0) {
  272.         /*
  273.          * The RCS file is the same version as the user file
  274.          */
  275.         if (TS_User[0] == '\0') {
  276.             /*
  277.              * There is no user file, so note that it was lost
  278.              * and extract a new version
  279.              */
  280.             if (strcmp(command, "checkout") != 0 &&
  281.             strcmp(command, "co") != 0 &&
  282.             strcmp(command, "get") != 0)
  283.             warn(0, "warning: %s was lost", update_user);
  284.             (void) strcat(Olist, " ");
  285.             (void) strcat(Olist, User);
  286.         } else if (strcmp(TS_User, TS_Rcs) == 0) {
  287.             /*
  288.              * The user file is still unmodified, so nothing
  289.              * special at all to do -- no lists updated
  290.              */
  291.         } else {
  292.             /*
  293.              * The user file appears to have been modified, but
  294.              * we call No_Difference to verify that it really
  295.              * has been modified -- it updates the Mlist,
  296.              * if necessary.
  297.              */
  298.             (void) No_Difference(0);
  299.         }
  300.         } else {
  301.         /*
  302.          * The RCS file is a newer version than the user file
  303.          */
  304.         if (TS_User[0] == '\0') {
  305.             /*
  306.              * There is no user file, so just get it
  307.              */
  308.             if (strcmp(command, "checkout") != 0 &&
  309.             strcmp(command, "co") != 0 &&
  310.             strcmp(command, "get") != 0)
  311.             warn(0, "warning: %s was lost", update_user);
  312.             (void) strcat(Olist, " ");
  313.             (void) strcat(Olist, User);
  314.         } else if (strcmp(TS_User, TS_Rcs) == 0) {
  315.             /*
  316.              * The user file is still unmodified, so just get it
  317.              * as well
  318.              */
  319.             (void) strcat(Olist, " ");
  320.             (void) strcat(Olist, User);
  321.         } else {
  322.             /*
  323.              * The user file appears to have been modified; we call
  324.              * No_Difference to verify this for us, and it updates
  325.              * Glist if it has really been modified, and Olist if
  326.              * it hasn't
  327.              */
  328.             (void) No_Difference(1);
  329.         }
  330.         }
  331.     }
  332.     }
  333.     return (ret);
  334. }
  335. @
  336.  
  337.  
  338. 1.1
  339. log
  340. @Initial revision
  341. @
  342. text
  343. @d212 1
  344. d215 1
  345. @
  346.